package com.rain.jwt.config;

import com.rain.jwt.common.BizException;
import com.rain.jwt.common.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author: wu
 * @date: 2021/9/25
 */
@ControllerAdvice
public class GlobalExceptionHandler  {
    private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);

    @ExceptionHandler(value = BizException.class)
    @ResponseBody
    public Result bizExceptionHandler(BizException e){
        log.error("发生未知异常",e);
        return Result.error(e);
    }

    @ExceptionHandler(value =Exception.class)
    @ResponseBody
    public Result exceptionHandler(Exception e){
        log.error("发生未知异常",e);
        return Result.error(e);
    }


}
